home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / A / AxoCalculator Package / AxoCalculator Documentation / Getting Started < prev    next >
Encoding:
Text File  |  1993-03-12  |  5.0 KB  |  210 lines  |  [TEXT/AxoC]

  1.  
  2. Getting Started with AxoCalculator
  3.  
  4. Contents
  5.  
  6. •    Basic arithmetic
  7. •    List of operators 
  8. •    Complex expressions
  9. •    Built in functions
  10. •    Named variables
  11. •    Declaring an array
  12. •    Initializing an array using a program
  13. •    Initializing an array using a list of values
  14. •    Array arithmetic
  15.  
  16. Hint : Use "Undo" under the "Edit" menu (or -Z) as a convenient way
  17.           to deleted text output from AxoCalculator.
  18.  
  19.  
  20. Basic Arithmetic
  21.  
  22. To perform a calculation, type in any arithmetic expression then press the "enter" key. For example, place the flashing insert cursor anywhere in the next line, then press "enter". 
  23.  
  24. 2 + 2 
  25.  
  26. (Note: The slight delay is due to the large size of this text file.)
  27.  
  28.  
  29. Here is another example demonstrating the use of brackets to control the order of calculation, and exponentiation ( ** or ^ ). 
  30.  
  31. (55+6.6*10) / (3 ** 3)
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. List of Operators
  39.  
  40.     +        Addition
  41.     -        Subtraction
  42.     /        Division
  43.     *        Multiplication
  44.     ^        Raise to the power
  45.     **        Alternative raise to the power
  46.     Div    Integer division
  47.     \        Alternative integer division
  48.     Mod    Remainder after integer division
  49.     ++        Increment
  50.     --        Decrement
  51.     
  52.     >        Greater than
  53.     <        Less than
  54.     >=        Greater than or equal to
  55.     <=        Less than or equal to
  56.     =        Is equal to
  57.     <>        Is not equal to
  58.     !=        Alternative is not equal to
  59.     and    Logical "and"
  60.     or        Logical "or"
  61.     not    Logical "not"
  62.     &        Alternative logical "and"
  63.     |        Alternative logical "or"
  64.     &&        Alternative logical "and"
  65.     ||        Alternative logical "or"
  66.     !        Alternative logical "not"
  67.  
  68. Built in Functions
  69.  
  70. AxoCalculator has many built in functions. For a complete list see the document "Built in Functions". Here are three examples showing various uses of these functions. 
  71.  
  72. pi * 2.25 ^ 2
  73. sin(30) + cos(-60) 
  74. 500 * exp( -25 * pi * tan(15.4) / 4 )
  75.  
  76. Named Variables
  77.  
  78. AxoCalculator supports named variables.  As an example, execute the following three expressions. You can execute each expression in turn, but it is faster to select all three lines using the mouse, then press "enter".
  79.  
  80. a = 7
  81. b = 100
  82. a+b
  83.  
  84.  
  85. Declaring an Array
  86.  
  87. AxoCalculator supports one dimensional arrays and array calculations. Execute one of the following expressions to create a new array. 
  88.  
  89. Note : If you wish to test the example array expressions below
  90.           please execute only those associated with the currently
  91.           selected language ("Settings" under the "Calculator" menu), 
  92.           and execute them in the order they occur.
  93.  
  94.  
  95. In any Language
  96. newArray (myArr, 50)
  97.  
  98. In Pascal
  99. VAR  myArr :  Array[1..50]
  100.  
  101. In Fortran
  102. Real myArr(50)
  103.  
  104. In Basic
  105. DIM  myArr(50)
  106.  
  107. In C
  108. float myArr[50]
  109.  
  110. To verify that the array was created, select "Show Status" under the "Calculator" menu. "myArr" should be listed as a global variable. 
  111.  
  112. Initializing an Array using a Program
  113.  
  114. When an array is declared, its elements are automatically set to zero. One way to initialize an array to non-zero values is within a program loop. 
  115.  
  116. In Pascal
  117. For j = 1 to 50 do myArr[j] = 5 
  118.  
  119. In Fortran
  120. Do j = 1, 50 
  121.   myArr(j) = 5 
  122. EndDo
  123.  
  124. In Basic
  125. For j = 1 to 50 
  126.   myArr(j) = 5 
  127. Next j
  128.  
  129. In C
  130. For (j = 0 ; j < 50 ; j++) myArr[j] = 5
  131.  
  132. Note that in C, "myArr" is indexed from 0 to 49. All other languages index "myArr" from 1 to 50. 
  133.  
  134. The various loop commands used above are described in the programming language documentation. To verify that the array has been initialized, check the first 4 elements by executing the following expression.
  135.  
  136. writeArr (myArr, 1, 4)
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. Initializing an Array from a List of Values
  147.  
  148. Several arrays may be declared and initialized in a single step if a tab delimited list of values is available. For example, select the following 11 lines, then press "enter". (Note: the columns are separated by tabs).
  149.  
  150. Array
  151. my1stArr  my2ndArr
  152. 1    9
  153. 2    8
  154. 3    7
  155. 4    6
  156. 5    5
  157. 6    4
  158. 7    3
  159. 8    2
  160. 9    1
  161.  
  162.  
  163. Verify that the arrays have been correctly initialized by executing the following expression.
  164.  
  165. In Pascal
  166. For j = 1 to 9 do writeLn (my1stArr[j],'  ',my2ndArr[j])
  167.  
  168. In Fortran
  169. Do i = 1, 9 
  170.   write (my1stArr(j),'  ',my2ndArr(j)) 
  171. EndDo
  172.  
  173. In Basic
  174. For j = 1 to 9 
  175.   print (my1stArr(j),"  ",my2ndArr(j))
  176. Next j
  177.  
  178. In C
  179. For (j = 0 ; j < 9 ; j++) printf (my1stArr[j]," ",my2ndArr[j])
  180.  
  181.  
  182.  
  183. Array Arithmetic
  184.  
  185. Arrays can be manipulated like ordinary numeric variables. For example the following expression multiplies every element of "myArr" by 5 and adds 5. The second line checks the values of some array elements.
  186.  
  187. myArr = myArr * 5 + 5
  188. writeArr (myArr, 45, 50)
  189.  
  190.  
  191. Arrays may also be added or multiplied together and the result assigned to a new array created "on the fly".
  192.  
  193. newArr = my1stArr * my2ndArr
  194. writeArr (newArr)
  195.  
  196.  
  197. Most built in functions work with arrays. The function is applied to each element of the array, and a new array returned. 
  198.  
  199. sinArr = sin(2 * newArr)
  200. writeArr (sinArr)
  201.  
  202.  
  203. Since each new array takes up additional memory, you should avoid creating lots of large arrays. If memory becomes a problem, unload arrays when you are finished with them. The following expression unloads all the arrays created during this tutorial.
  204.  
  205. Unload (myArr, my1stArr, my2ndArr, newArr, sinArr)
  206.  
  207.  
  208.  
  209.  
  210.